<!DOCTYPE html>
<html lang="en">
<head>
    <title id="Description">Using jqxTreeGrid with JSP and MySQL</title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdatatable.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxtreegrid.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            // prepare the data
            var source = {
                dataType: "json",
                dataFields: [{
                    name: 'EmployeeID',
                    type: 'number'
                }, {
                    name: 'FirstName',
                    type: 'string'
                }, {
                    name: 'LastName',
                    type: 'string'
                }, {
                    name: 'Title',
                    type: 'string'
                }, {
                    name: 'ReportsTo',
                    type: 'number'
                }],
                hierarchy: {
                    keyDataField: {
                        name: 'EmployeeID'
                    },
                    parentDataField: {
                        name: 'ReportsTo'
                    }
                },
                id: 'EmployeeID',
                url: 'jsp/select-tree-data.jsp',
                async: true
            };
            var dataAdapter = new $.jqx.dataAdapter(source);
            // create Tree Grid
            $("#treeGrid").jqxTreeGrid({
                width: 500,
                source: dataAdapter,
                ready: function() {
                    // expand row with 'EmployeeID = 2'
                    $("#treeGrid").jqxTreeGrid('expandRow', 2);
                },
                columns: [{
                    text: 'FirstName',
                    dataField: 'FirstName',
                    minWidth: 100,
                    width: 125
                }, {
                    text: 'LastName',
                    dataField: 'LastName',
                    width: 125
                }, {
                    text: 'Title',
                    dataField: 'Title',
                    width: 250
                }]
            });
        });
    </script>
</head>
<body class='default'>
    <div id="treeGrid">
    </div>
</body>
</html>